<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>客户信息</title>
 <%@ include file="/page/include.jsp" %>
</head>
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/statics/plugins/bootstrap-switch/bootstrap-switch.min.css" />
<script src="<%=basePath%>/statics/js/webform.js" type="text/javascript"></script>
<style type="text/css">
.bootstrap-switch.bootstrap-switch-large .bootstrap-switch-handle-off, .bootstrap-switch.bootstrap-switch-large .bootstrap-switch-handle-on, .bootstrap-switch.bootstrap-switch-large .bootstrap-switch-label {
    line-height: 1;
}
</style>
<body class="nav-md" style="background-color: #f7f7f7">
	<div class="container body">
		<div class="main_container">
			<div class="framebody" style="min-height: 100%;" role="main">
				<!-- <blockquote class="ui-elem-quote">
  					客户列表>新增客户
				</blockquote>  -->
				<div class="row">
					<div class="col-md-12 col-sm-12 col-xs-12">
						<div class="x_panel">
							<div class="x_content">
								<div class="tabbable">
									<ul class="nav nav-tabs" id="myTabs">
										<li class="${customerId == null ? 'active' :'' }">
											<a data-toggle="tab" href="#companyInfoContent">
												基本信息
											</a>
										</li>
										<li class="${customerId != null ? 'active' :'' }">
											<a data-toggle="tab" href="#customerInfoContent">
												人员信息
											</a>
										</li>
										<li>
											<a data-toggle="tab" href="#billingContent">
												开票信息
											</a>
										</li>
										<li>
											<a data-toggle="tab" href="#deliverModeContent">
												配件方式
											</a>
										</li>
										<li>
											<a data-toggle="tab" href="#ExpressCongfigContent">
												常用物流
											</a>
										</li>
										<li>
											<a data-toggle="tab" href="#customerVisitLog">
												用户行为
											</a>
										</li>
										<li>
											<a data-toggle="tab" href="#customerOrder">
												销售订单
											</a>
										</li>
										<li>
											<a data-toggle="tab" href="#customerPoint">
												客户积分
											</a>
										</li>
									</ul>

									<div class="tab-content">
										<!-- 基本信息 -->
										<div id="companyInfoContent" class="${customerId == null ? 'tab-pane in active' :'tab-pane' }">
											<div class="x_panel"> 
												<div class="x_content"> 
													<form class="form-horizontal form-label-left" id="companyInfoForm"  method="post" action="${pageContext.request.contextPath}/company/saveOrUpdateCompany">
														<input type="hidden"  id="companyId" name="id" value="${company.id }" >
														<div class="item form-group">
															<label class="control-label col-md-1 col-xs-12 form-item-label-100" for="companyName"><span class="required">*</span>单位名称: 
															</label>
															<div class="col-md-3 col-sm-3 col-xs-12">
																<input id="companyName" name="companyName" value="${company.companyName }" class="form-control col-md-3 col-xs-12" placeholder="公司名称必须和营业执照上保持一致"  type="text">
															</div>
															<!-- <div class="col-md-2 col-sm-2 col-xs-2">
																<a href="#" style="color:#85ADF6; line-height:32px;"><i class="fa fa-plus fa-fw"></i>更换客户单位</a>
															</div> -->
															<label class="control-label col-md-1 col-xs-12 form-item-label-100" for="fax">传真号码: 
															</label>
															<div class="col-md-3 col-sm-3 col-xs-12">
																<input id="fax" name="fax" value="${company.fax }" class="form-control col-md-3 col-xs-12" placeholder="传真号码" type="text">
															</div>
														</div>
														<div class="item form-group">
															<label class="control-label col-md-1 col-sm-1 col-xs-12 form-item-label-100" for="tel">固定电话: 
															</label>
															<div class="col-md-3 col-sm-3 col-xs-12">
																<input id="tel" name="tel" value="${company.tel }" class="form-control col-md-3 col-xs-12" placeholder="固定电话"  type="text">
															</div>
															<label class="control-label col-md-1 col-sm-1 col-xs-12 form-item-label-100" for="customerLevel"><span class="required">*</span>客户级别: 
															</label>
															<div class="col-md-3 col-sm-3 col-xs-12">
																<select class="selectpicker form-control col-md-3 col-xs-12" id="customerLevel" name="customerLevel" init-value="${company.customerLevel }" value="${company.customerLevel }" data-live-search="true" title="客户级别">
																</select>
															</div>
														</div>
														<div class="item form-group">
															<%-- <label class="control-label col-md-1 col-sm-1 col-xs-12 form-item-label-100" for="customerType"><span class="required">*</span>客户类型: 
															</label>
															<div class="col-md-3 col-sm-3 col-xs-12">
																<select class="selectpicker form-control col-md-3 col-xs-12" id="customerType" name="customerType" init-value="${company.customerType }" value="${company.customerType }" data-live-search="true" title="客户类型">
																</select>
															</div> --%>
															<label class="control-label col-md-1 col-sm-1 col-xs-12 form-item-label-100" for="marketGrade"><span class="required">*</span>市场等级: 
															</label>
															<div class="col-md-3 col-sm-3 col-xs-12">
																<select class="selectpicker form-control col-md-3 col-xs-12" id="marketGrade" name="marketGrade" init-value="${company.marketGrade }" value="${company.marketGrade }" data-live-search="true" title="市场等级">
																</select>
															</div>
															<label class="control-label col-md-1 col-sm-1 col-xs-12 form-item-label-100" for="customerFactor"><span class="required">*</span>客户系数: 
															</label>
															<div class="col-md-3 col-sm-3 col-xs-12">
																<input id="customerFactor" name="customerFactor" value="${company.customerFactor }" class="form-control col-md-3 col-xs-12" placeholder="客户系数" type="text">
															</div>
														</div>
														<div class="item form-group">
															
															<label class="control-label col-md-1 col-sm-1 col-xs-12 form-item-label-100" for="salesmanCode" >业务员: 
															</label>
															<div class="col-md-3 col-sm-3 col-xs-12">
																<select class="selectpicker form-control col-md-3 col-xs-12" id="salesmanCode" name="salesmanCode" init-value="${company.salesmanCode }" value="${company.salesmanCode }" data-live-search="true" title="业务员">
																</select>
															</div>
														</div>
														<%-- <div class="item form-group">
															<label class="control-label col-md-1 col-sm-1 col-xs-12 form-item-label-100" for="registAddr">注册地址: 
															</label>
															<div class="col-md-3 col-sm-3 col-xs-12">
																<input id="registAddr" name="registAddr" value="${company.registAddr }" class="form-control col-md-3 col-xs-12" placeholder="注册地址"  type="text">
															</div>
														</div> --%>
														<div class="item form-group">
															<label class="control-label col-md-1 col-sm-1 col-xs-12 form-item-label-100" for="customerFactor"><!-- <span class="required">*</span> -->收货地址: 
															</label>
															<div class="col-md-8">
																<select id="province1" data-width="20%" name="provinceCode" init-value="${company.provinceCode }" value="${company.provinceCode }" class="selectpicker" title="省" data-live-search="true" ></select>
																&nbsp;
																<select id="city1" data-width="20%" name="cityCode" init-value="${company.cityCode }" value="${company.cityCode }" class="selectpicker" title="市" data-live-search="true" ></select>
																&nbsp;
																<select id="area1" data-width="20%" name="areaCode" init-value="${company.areaCode }" value="${company.areaCode }" class="selectpicker" title="区" data-live-search="true" ></select>
																&nbsp;
																<select id="street1" data-width="20%" name="streetCode" init-value="${company.streetCode }" value="${company.streetCode }" class="selectpicker" title="街道" data-live-search="true" ></select>
																&nbsp;
															</div>
															<c:if test="${isSalesman == '0' }">
																<a id="addNewAddr" href="#" style="color:#85ADF6; line-height:32px;"><i class="fa fa-plus fa-fw"></i>新增地址</a>
															</c:if>
														
															<input type="hidden" name="provinceName" value="${company.provinceName }">
															<input type="hidden" name="cityName" value="${company.cityName }">
															<input type="hidden" name="areaName" value="${company.areaName }">
															<input type="hidden" name="streetName" value="${company.streetName }">
														</div>
														<div class="item form-group">
															<label class="control-label col-md-1 col-sm-1 col-xs-12 form-item-label-100" for="address"><!-- <span class="required">*</span> -->详细地址: 
															</label>
															<div class="col-md-5 col-sm-5 col-xs-12">
																<input id="address1" name="address" value="${company.address }" class="form-control col-md-3 col-xs-12" placeholder="详细地址"  type="text">
																<span>上面所在地区和详细地址将为客户的默认收货地址</span>
															</div>
														</div>
														<div id="branchCompanyAddrDiv">
															<c:forEach var="extend" items="${company.companyAddressExtendInfo }" varStatus="status">
															<div class="extendAddress">
																<div class="item form-group branchAddrDiv${status.index+1 }">
																	<label class="control-label col-md-1 col-sm-1 col-xs-12 form-item-label-100" for="customerFactor">收货地址${status.index+1 }:
																	</label>	
																	<div class="col-md-8 col-sm-8 col-xs-8 ">	
																		<select id="province_b${status.index+1 }" data-width="20%" init-value="${extend.provinceCode }" class="selectpicker extend_provinceCode" title="省" validate="{required:true,messages:{required:'请填写省'}}" data-live-search="true" ></select>
																		&nbsp;
																		<select id="city_b${status.index+1 }" data-width="20%" init-value="${extend.cityCode }" class="selectpicker extend_cityCode" title="市" validate="{required:true,messages:{required:'请填写市'}}" data-live-search="true" ></select>
																		&nbsp;
																		<select id="area_b${status.index+1 }" data-width="20%" init-value="${extend.areaCode }" class="selectpicker extend_areaCode" title="区" validate="{required:true,messages:{required:'请填写区'}}" data-live-search="true" ></select>
																		&nbsp;
																		<select id="street_b${status.index+1 }" data-width="20%" init-value="${extend.streetCode }" class="selectpicker extend_streetCode" title="街道" validate="{required:true,messages:{required:'请填写街道'}}" data-live-search="true" ></select>
																	</div>
																	<div class="col-md-1 col-sm-1 col-xs-1">
																		<a onclick="delNewAddr(${status.index+1 })" class="delNewAddr" href="#" style="color:#85ADF6; line-height:32px;color:red;"><i class="fa fa-minus fa-fw"></i>删除</a>
																	</div>
																</div>
																<div class="item form-group branchAddrDiv${status.index+1 }">
																	<label class="control-label col-md-1 col-sm-1 col-xs-12 form-item-label-100" for="">详细地址${status.index+1 }:
																	</label>
																	<div class="col-md-5 col-sm-5 col-xs-12">
																		<input id="address_b${status.index+1 }" value="${extend.address }" class="form-control col-md-3 col-xs-12 extend_address" placeholder="详细地址"  type="text">
																	</div>
																</div>
															</div>
															</c:forEach>
														</div>
														<div class="item form-group">
															<%-- <input type="hidden" name="allowedPayType" value="${company.allowedPayType }" /> --%>
															<label class="control-label col-md-1 col-sm-1 col-xs-12 form-item-label-100" ><span class="required">*</span>付款方式: 
															</label>
															<div class="col-md-2 col-sm-2 col-xs-12">
																<label class="control-label" for="allowedPayType"><input type="checkbox" name="allowedPayType" <c:if test="${empty company.allowedPayType }">checked</c:if> <c:if test="${company.allowedPayType eq '01' or company.allowedPayType eq '01,02'}">checked</c:if> value="01" class="form-control" /> 立即付款</label>
																&nbsp;
																<label class="control-label" for="allowedPayType"><input type="checkbox" name="allowedPayType" id="codPay" <c:if test="${company.allowedPayType eq '02' or company.allowedPayType eq '01,02'}">checked</c:if> value="02" class="form-control" /> 货到付款</label>
																&nbsp;
															</div>
															<label class="control-label col-md-1 col-sm-1 col-xs-12" for="paymentDays">付款账期:</label>
															<div class="col-md-2 col-sm-2 col-xs-12">
																<input id="paymentDays" name="paymentDays" value="${company.paymentDays }" class="form-control col-md-3 col-xs-12" placeholder="货到付款时必填"  type="text">
															</div>
														</div>
														<div class="item form-group">
															<label class="control-label col-md-1 col-sm-1 col-xs-12 form-item-label-100" ><span class="required">*</span>是否允许用户退货: 
															</label>
															<div class="col-md-4 col-sm-4 col-xs-12 ">
																<label class="control-label" for="allowBackFlag"><input type="radio" name="allowBackFlag" <c:if test="${company.allowBackFlag eq '1' }">checked</c:if> value="1" class="form-control" /> 允许</label>
																&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
																<label class="control-label" for="allowBackFlag"><input type="radio" name="allowBackFlag" <c:if test="${company.allowBackFlag eq '0' }">checked</c:if> <c:if test="${empty company.allowBackFlag }">checked</c:if> value="0" class="form-control" /> 不允许</label>
															</div>
														</div>
														
														<div class="item form-group">
					                                        <label class="control-label col-md-1 col-sm-1 col-xs-12 form-item-label-100" for="remark">备注： </label>
					                                        <div class="col-md-5 col-sm-5 col-xs-12">
					                                            <textarea id="remark" name="remark" maxlength="100" class="form-control col-md-12">${company.remark }</textarea>
					                                        </div>
					                                    </div>
														
														<div class="item form-group">
															<label class="control-label col-md-1 col-sm-1 col-xs-12 form-item-label-100" for="coperateFlag">合作中: 
															</label>
															<div class="col-md-3 col-sm-3 col-xs-12">
																<div class="switch" data-on="danger" data-off="primary" data-size="small">
																    <input type="checkbox" name="coperateFlag" <c:if test="${company.coperateFlag eq '0' }">value="0"</c:if> <c:if test="${company.coperateFlag eq '1' }">value="1"  checked</c:if> />
																</div>
															</div>
														</div>
													</form>
													<div class="form-btn-content">
														<c:if test="${isSalesman == '0' }">
															<a id="btn_save_baseInfo" class="btn btn-primary">保存并下一步</a>
														</c:if>
													</div>
												 </div>
											</div>
										</div>
										<!-- 人员信息 -->
										<div id="customerInfoContent"  class="${customerId != null ? 'tab-pane in active' :'tab-pane' }">
											<div class="x_panel"> 
												<div class="x_content">
													<div class="row" style="padding-bottom: 10px;padding-left:10px;">
														<c:if test="${isSalesman == '0' }">
															&nbsp;&nbsp;<a class="btn btn-success btn-sm" id="btnAddCustomer"><i class="fa fa-plus fa-fw"></i>新增</a>
														</c:if>
													</div>
													<div class="row">
														<table id="customerTable" class="table"></table>
													</div>
													<div class="form-btn-content">
														<c:if test="${isSalesman == '0' }">
															<a id="btn_save_customerInfo" class="btn btn-primary">下一步</a>
															<a id="btn_back_customerInfo"class="btn btn-default">上一步</a>
														</c:if>
													</div>
												</div>
											</div>
										</div>
										<!-- 开票信息 -->
										<div id="billingContent" class="tab-pane">
											<div class="x_panel"> 
												<div class="x_content">
													<c:if test="${isSalesman == '0' }">
														<div class="row" style="padding-bottom: 10px;padding-left: 10px;">
															<a class="btn btn-success btn-sm" id="btnAddInvoice" onclick="javascript: doAddBillingInfo();"><i class="fa fa-plus fa-fw"></i>新增</a>
														</div>
													</c:if>
													<row>
														<table id="companyInvoiceTable" class="table"></table>
													</row>
													<div class="form-btn-content">
														<a id="btn_save_billingInfo" class="btn btn-primary" onclick="javascript: showTabContent(3);">下一步</a>
														<a id="btn_back_billingInfo"class="btn btn-default" onclick="javascript: showTabContent(1);">上一步</a>
													</div>
												</div>
											</div>
										</div>
										<!-- 配件方式 -->
										<div id="deliverModeContent" class="tab-pane">
											<div class="x_panel"> 
												<div class="x_content">
													<row>
														<table id="deliveryModeTable" class="table"></table>
													</row>
													
													<div class="form-btn-content">
														<c:if test="${isSalesman == '0' }">
															<a id="btn_save_deliverModeInfo" class="btn btn-primary">保存并下一步</a>
															<a id="btn_back_deliverModeInfo"class="btn btn-default">上一步</a>
														</c:if>
													</div>
												</div>
											</div>
										</div>
										
										<!-- 常用物流 -->
										<div id="ExpressCongfigContent" class="tab-pane">
											<div class="x_panel"> 
												<div class="x_content">
													<row>
														<form class="form-horizontal form-label-left" novalidate id="billingInfoForm"  method="post" action="${pageContext.request.contextPath}/company/saveCompanyBillingInfo">
															<div class="item form-group">
																<div class="col-md-2 col-sm-2 col-xs-12">
																	<label class="control-label" for="expressType">
																	<input type='checkbox' name='expressType'  value='1'  />&nbsp;普通物流-免运费
																	</label>
																</div>
																<div class="col-md-5 col-sm-5 col-xs-12">
																	<select id="commonExpressAddress" data-width="100%"  init-value="" value="" class="selectpicker" title="请选择免运费地址" data-live-search="true" multiple data-actions-box="true" ></select>
																</div>
															</div>
															<div class="item form-group">
																<div class="col-md-2 col-sm-2 col-xs-12">
																	<label class="control-label" for="expressType">
																	<input type='checkbox' name='expressType'  value='2' />&nbsp;普通物流-全部地址免运费
																	</label>
																</div>
															</div>
															<div class="item form-group">
																<div class="col-md-2 col-sm-2 col-xs-12">
																	<label class="control-label" for="expressType">
																	<input type='checkbox' name='expressType'  value='3'  />&nbsp;快递物流-免运费
																	</label>
																</div>
																<div class="col-md-5 col-sm-5 col-xs-12">
																	<select id="expressAddress" data-width="100%"  init-value="" value="" class="selectpicker" title="请选择免运费地址" data-live-search="true" multiple data-actions-box="true" ></select>
																</div>
															</div>
															<div class="item form-group">
																<div class="col-md-2 col-sm-2 col-xs-12">
																	<label class="control-label" for="expressType">
																	<input type='checkbox' name='expressType'  value='4' />&nbsp;快递物流-全部地址免运费
																	</label>
																</div>
															</div>
														</form>
													</row>
													
													<div class="form-btn-content">
														<c:if test="${isSalesman == '0' }">
															<a id="btn_save_expressConfig" class="btn btn-primary">保存</a>
															<a id="btn_back_expressConfig"class="btn btn-default">上一步</a>
														</c:if>
													</div>
												</div>
											</div>
										</div>
										
										
										<!-- 用户行为-->
										<div id="customerVisitLog" class="tab-pane">
											<div class="x_panel"> 
												<div class="x_content">
													<div class="row">
														<table id=customerVisitLogTable class="table"></table>
													</div>
												</div>
											</div>
										</div>
										
										<!-- 销售订单-->
										<div id="customerOrder" class="tab-pane">
											<div class="x_panel"> 
												<div class="x_content">
													<div class="row">
														<table id=customerOrderTable class="table"></table>
													</div>
												</div>
											</div>
										</div>
										
										<!-- 客户积分-->
										<div id="customerPoint" class="tab-pane">
											<div class="row">
												<div class="col-md-3 col-sm-3 col-xs-3 ">
													<select class="selectpicker form-control control-label" id="customerListSel" name="customerListSel" data-live-search="true" title="请选择">
														<c:forEach items="${customerList }" var="customer">
															<option value="${customer.id}">${customer.userName }</option>
														</c:forEach>
													</select>
												</div>
												<div class="col-md-9 col-sm-9 col-xs-9 ">
												</div>
											</div>
											<div class="row" style="margin:0px;margin-top:10px;">
												<table id=customerPointTable class="table"></table>
											</div>
										</div>
										
									</div>
								</div>
								
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<%-- 隐藏域 begin --%>
		<input type="hidden" id="isSalesman" value="${isSalesman }" />
		<input type="hidden" id="layer_opt_status" />
		<%-- 隐藏域 end --%>
	</div>



	<%-- 开票信息弹出框 begin --%>
	<div class="modal fade" id="billingModal" tabindex="-1" data-backdrop="static" role="dialog" aria-labelledby="billingModalLabel" aria-hidden="true">
		<form class="form-horizontal form-label-left" novalidate id="billingInfoForm" method="post"
			action="${pageContext.request.contextPath}/company/saveCompanyBillingInfo">
			<div class="modal-dialog" style="width: 50%; min-height: 450px; height: 500px; max-height: 500px;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
						<h4 class="modal-title" id="billingModalLabel">编辑收货地址</h4>
					</div>
					<div class="modal-body">
						<div class="item form-group">
							<label class="control-label col-md-3 col-sm-3 col-xs-3" for="billingCompanyName"><span class="required">*</span>单位名称: </label>
							<div class="col-md-8 col-sm-8 col-xs-8">
								<input id="billingCompanyName" name="billingCompanyName" class="form-control col-md-3 col-xs-12" placeholder="单位名称" type="text" maxlength="100">
							</div>
						</div>
						<div class="item form-group">
							<label class="control-label col-md-3 col-sm-3 col-xs-3" for="taxNo"><span class="required">*</span>纳税人识别号: </label>
							<div class="col-md-8 col-sm-8 col-xs-8">
								<input id="taxNo" name="taxNo" class="form-control col-md-3 col-xs-12" placeholder="纳税人识别号" type="text" maxlength="20">
							</div>
						</div>
						<div class="item form-group">
							<label class="control-label col-md-3 col-sm-3 col-xs-3" for="bankAddress">注册地址:</label>
							<div class="col-md-8 col-sm-8 col-xs-8">
								<input id="registeAddress" name="registeAddress" class="form-control col-md-3 col-xs-12" placeholder="注册地址" type="text" maxlength="100">
							</div>
						</div>
						<div class="item form-group">
							<label class="control-label col-md-3 col-sm-3 col-xs-3" for="registePhone">注册电话:</label>
							<div class="col-md-8 col-sm-8 col-xs-8">
								<input id="registePhone" name="registePhone" class="form-control col-md-3 col-xs-12" placeholder="注册电话" type="text" maxlength="20">
							</div>
						</div>
						<div class="item form-group">
							<label class="control-label col-md-3 col-sm-3 col-xs-3" for="openBankName">开户银行: </label>
							<div class="col-md-8 col-sm-8 col-xs-8">
								<input id="openBankName" name="openBankName" class="form-control col-md-3 col-xs-12" placeholder="开户银行" type="text" maxlength="100">
							</div>
						</div>
						<div class="item form-group">
							<label class="control-label col-md-3 col-sm-3 col-xs-3" for="bankAccount">银行账号: </label>
							<div class="col-md-8 col-sm-8 col-xs-8">
								<input id="bankAccount" name="bankAccount" class="form-control col-md-3 col-xs-12" placeholder="银行账号" type="text" maxlength="30">
							</div>
						</div>
					</div>
					<div class="modal-footer">
						<input type="hidden" id="invoiceId" name="invoiceId">
						<c:if test="${isSalesman == '0' }">
							<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
							<button type="button" class="btn btn-primary" onclick="javascript: doSaveBilling();">保存</button>
						</c:if>
					</div>
				</div>
			</div>
		</form>
	</div>
	<%-- 弹出框 begin --%>



<script type="text/javascript" 	src="${rootPath}/statics/js/jquery.metadata.js"></script>
<script type="text/javascript"  src="${rootPath}/statics/plugins/bootstrap-switch/bootstrap-switch.min.js"></script>
<script type="text/javascript"  src="${rootPath}/js/customer/company_form.js?v=20180423"></script>
</body>
</html>